package com.htpay.model.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.springframework.format.annotation.DateTimeFormat;

import java.io.Serializable;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.Date;

/**
 * 商户结算记录
 */
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
public class MerchantSettlementFlow implements Serializable {
    private static final long serialVersionUID = 1L;

    /**
     * 订单ID
     */
    @TableId(type = IdType.AUTO)
    private Integer id;

    /**
     * 商户ID
     */
    private Integer merchantId;

    /**
     * 结算方式
     */
    private char withdrawType;

    /**
     * 保留2位小数：四舍五入
     *
     * @param withdrawMoney
     */
    public void setWithdrawMoney(BigDecimal withdrawMoney) {
        this.withdrawMoney = withdrawMoney.setScale(2, RoundingMode.HALF_UP).toString();
    }

    public void setWithdrawMoneyWithStr(String withdrawMoney) {
        this.withdrawMoney = withdrawMoney;
    }

    /**
     * 提现金额
     */
    private String withdrawMoney;

    /**
     * 收款人姓名
     */
    private String payeeName;

    /**
     * 银行编码
     * 默认的支付宝001、微信002保留
     * <p>
     * 银行编码从：003开始
     */
    private String bankId;

    /**
     * 收款账号开户行
     */
    private String bankName;

    /**
     * 收款账户
     */
    private String payeeAct;

    /**
     * 提现状态：
     * 1-未审核
     * 2-审核成功
     * 3-拒绝审核
     * 4-代付失败
     */
    private char withdrawStatus;

    /**
     * 备注、描述
     */
    private String remark;

    /**
     * 创建人
     */
    private String createBy;

    /**
     * 创建时间
     */
    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date createTime;

    /**
     * 更新人
     */
    private String updateBy;

    /**
     * 更新时间
     */
    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date updateTime;
}
